/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sismol.cartography;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

/**
 *
 * @author koji
 */
@Entity
public class Trecho implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private Linha linha;

    private Ponto pontoA;
    private Ponto pontoB;

    private Long distancia;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getDistancia() {
        return distancia;
    }

    public void setDistancia(Long distancia) {
        this.distancia = distancia;
    }

    @ManyToOne
    public Linha getLinha() {
        return linha;
    }

    public void setLinha(Linha linha) {
        this.linha = linha;
    }

    @OneToOne
    public Ponto getPontoA() {
        return pontoA;
    }

    public void setPontoA(Ponto pontoA) {
        this.pontoA = pontoA;
    }

    @OneToOne
    public Ponto getPontoB() {
        return pontoB;
    }

    public void setPontoB(Ponto pontoB) {
        this.pontoB = pontoB;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Trecho)) {
            return false;
        }
        Trecho other = (Trecho) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sismol.cartography.Trecho[id=" + id + "]";
    }

}
